package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.ProductCategory;
import com.shrcl.engineerprocess.domain.proxy.ProductCategoryProxy;
import com.uniquesoft.uidl.validation.Validates;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("PRODUCTCATEGORY_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "productcategory")
public class ProductCategoryImpl extends BaseModelObject implements ProductCategory {
  public ProductCategoryImpl() {
    super();
  }
  
  private String brand;
  
  public String getBrand() {
    return this.brand;
  }
  
  public ProductCategory setBrand(final String brand) {
    this.brand = brand;
    return this;			
    
  }
  
  private String productName;
  
  public String getProductName() {
    return this.productName;
  }
  
  public ProductCategory setProductName(final String productName) {
    this.productName = productName;
    return this;			
    
  }
  
  public void update(final Procedure1<? super ProductCategory> updater) {
    updater.apply(this);
    this.checkValid();
  }
  
  public void checkValid() {
    boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(this.brand);
    boolean _not = (!_isNullOrEmpty);
    Validates.Assert(_not, "\u54C1\u724C\u4E0D\u80FD\u4E3A\u7A7A");
    boolean _isNullOrEmpty_1 = StringExtensions.isNullOrEmpty(this.productName);
    boolean _not_1 = (!_isNullOrEmpty_1);
    Validates.Assert(_not_1, "\u4EA7\u54C1\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");
  }
  
  public static ProductCategory create(final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.ProductCategory productCategory = new com.shrcl.engineerprocess.domain.impl.ProductCategoryImpl(
    );
    objectFactory.create(productCategory);
    return productCategory;			
    
  }
  
  public static ProductCategory createProductCategoryImpl(final IObjectFactory objectFactory, final Procedure1<ProductCategory> init) {
    com.shrcl.engineerprocess.domain.ProductCategory productCategory = new com.shrcl.engineerprocess.domain.impl.ProductCategoryImpl(
    );
    objectFactory.create(productCategory);
    init.apply(productCategory);
    
    return productCategory;			
    
  }
  
  public ProductCategoryProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.ProductCategoryProxy proxy = new com.shrcl.engineerprocess.domain.proxy.ProductCategoryProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
